home *** CD-ROM | disk | FTP | other *** search
- /*
- * VirtuaLight's binary .VIB format API, sample 5
- * Written by Stephane Marty, 09/10/2001
- *
- * Displacement mapping test on a sphere
- * SAMPLE5.VS contains shader and displacement declarations.
- */
-
- #include "..\vlBinDef.h"
-
- void main(void)
- {
- viSPHERE sphere;
- viDISK disk;
- viCAMERA *cam;
- viGENERAL *gen;
- viSHAPE_MODIFIERS *shpmod;
- viPOINT_LIGHT *pl;
- viFILE *vib;
-
- // Open a new VIB file
- vib = viNewBinaryVIB("sample5.vib");
-
- // Add the camera (low adaptive antialiasing enabled)
- cam = viNewCamera();
- viSetInt(cam->Format.X, 256);
- viSetInt(cam->Format.Y, 256);
- viSetDbl(cam->FrameAspectRatio, 1.0);
- viSetVector(&cam->Location, 0, 3, -6);
- viSetVector(&cam->LookAt, 0, 1.5, 0);
- viSetVector(&cam->UpAxis, 0, 1, 0);
- viSetDbl(cam->FieldOfView, 40);
- viSetInt(cam->Antialiasing, 1);
- viDumpCamera(cam, vib);
-
- // Set the background color
- gen = viNewGeneral();
- viSetColor(&gen->Background, 0.098039*2, 0.098039*2, 0.392157*2);
- viDumpGeneral(gen, vib);
-
- // Add two pointlights
- pl = viNewPointLight();
- viSetColor(&pl->Intensity, 0.6, 0.6, 0.6);
- viSetVector(&pl->Position, 10, 30, -25);
- viDumpPointLight(pl, vib);
- viSetColor(&pl->Intensity, 0.7, 0.7, 0.7);
- viSetVector(&pl->Position, -15, 20, -20);
- viDumpPointLight(pl, vib);
-
- // A simple disk for the floor
- viPrimitive(vib);
- viSetVector(&disk.center, 0, 0, 0);
- viSetVector(&disk.normal, 0, 1, 0);
- viSetDbl(disk.radius, 200);
- viDumpDisk(&disk, vib);
- viPrimitiveShaderName("veins_pattern", vib);
- viEndPrimitive(vib);
-
- // The sphere with its shader...
- viPrimitive(vib);
- viSetVector(&sphere.center, 0, 1.5, 0);
- viSetDbl(sphere.radius, 1.5);
- viDumpSphere(&sphere, vib);
- viPrimitiveShaderName("ball", vib);
- // ...and its shape modifiers
- shpmod = viNewShapeModifiers();
- viSetInt(shpmod->ShapeSubdivisions.u, 128);
- viSetInt(shpmod->ShapeSubdivisions.v, 128);
- viSetString(shpmod->DisplacementMapping, "Emboss");
- viDumpShapeModifiers(shpmod, vib);
- viEndPrimitive(vib);
-
- // Close the VIB file
- viCloseBinaryVIB(vib);
-
- // Deallocate memory used
- free(cam);
- free(gen);
- free(pl);
- free(shpmod);
- }